package cn.iocoder.yudao.module.system.dal.mysql.message;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.system.dal.dataobject.message.MessageCountDo;
import cn.iocoder.yudao.module.system.dal.dataobject.message.MessageDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.system.controller.admin.message.vo.*;

/**
 * 站内信主题 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface MessageMapper extends BaseMapperX<MessageDO> {

    default PageResult<MessageDO> selectPage(MessagePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<MessageDO>()
                .eqIfPresent(MessageDO::getId, reqVO.getId())
                .likeIfPresent(MessageDO::getTitle, reqVO.getTitle())
                .eqIfPresent(MessageDO::getType, reqVO.getType())
                .eqIfPresent(MessageDO::getStatus, reqVO.getStatus())
                .eqIfPresent(MessageDO::getStudentId, reqVO.getStudentId())
                .likeIfPresent(MessageDO::getStudentName, reqVO.getStudentName())
                .likeIfPresent(MessageDO::getPhone, reqVO.getPhone())
                .likeIfPresent(MessageDO::getReply, reqVO.getReply())
                .likeIfPresent(MessageDO::getUpdater, reqVO.getUpdater())
                .eqIfPresent(MessageDO::getUserId, reqVO.getUserId())
                .eqIfPresent(MessageDO::getLeaveType, reqVO.getLeaveType())
                .neIfPresent(MessageDO::getType, reqVO.getType1())
                .in(MessageDO::getType,reqVO.getTypeIds())
                .orderBy(MessageDO.class, PageParam.DEFAULT_SORTING_FIELDS));
    }

    default List<MessageDO> selectList(MessageExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<MessageDO>()
                .eqIfPresent(MessageDO::getTitle, reqVO.getTitle())
                .eqIfPresent(MessageDO::getType, reqVO.getType())
                .eqIfPresent(MessageDO::getStatus, reqVO.getStatus())
                .eqIfPresent(MessageDO::getStudentId, reqVO.getStudentId())
                .eqIfPresent(MessageDO::getUserId, reqVO.getUserId())
                .orderBy(MessageDO.class, PageParam.DEFAULT_SORTING_FIELDS));
    }



    default List<MessageDO> selectList(Long studentId,Long userId) {
        return selectList(new LambdaQueryWrapperX<MessageDO>()
                .eqIfPresent(MessageDO::getStudentId, studentId)
                .eqIfPresent(MessageDO::getUserId, userId));
    }


    default List<MessageDO> selectList(Long studentId,List<String> statuss) {
        return selectList(new LambdaQueryWrapperX<MessageDO>()
                .eqIfPresent(MessageDO::getStudentId, studentId)
                .inIfPresent(MessageDO::getStatus, statuss));
    }


    List<MessageCountDo> getAllMessageCount();
}
